#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>

using namespace std;
map<int, vector<int> > dvcs;

const int N = 1e5 + 10;
const double eps = 1e-8;
struct vhc
{
    int d, v, a;
    double st;
}vhcs[N];
int state[N];
double vm[N];
int det[N];
int T, n, m, L, V;

inline double sp(int d, int v, int a, int p)
{
    if(a == 0) return v;
    int x = p - d;
    double v1 = sqrt(v * v + 2 * a * x);
    return v1;
}

int count(int x)
{
    int cnt = 0;
    for(int i = 0; i < n; i ++ )
    {
        if(vhcs[i].d > det[x]) continue;
        if(vhcs[i].a > 0) {if(sp(vhcs[i].d, vhcs[i].v, vhcs[i].a, det[x]) - V > eps) cnt ++;}
        else 
        {
            if(vhcs[i].v > V) cnt ++;
        }
    }
    return cnt;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    scanf("%d", &T);
    while(T -- )
    {
        int cnt = 0;
        scanf("%d%d%d%d", &n, &m, &L, &V);
        if(n < 25 && m < 25)
        {    
            for (int i = 0; i < n; i ++ )
            {
                scanf("%d%d%d", &vhcs[i].d, &vhcs[i].v, &vhcs[i].a);
                state[i] = 0;
                int v = vhcs[i].v, a = vhcs[i].a;
                if(a < 0) vhcs[i].st = vhcs[i].d + (v * v * 1.0) / (-a * 2.0);
                else vhcs[i].st = L + 1;
            }
            for(int i = 0; i < m; i ++ ) scanf("%d", &det[i]);
            for (int j = 0; j < n; j ++ )
            {
                for(int i = 0; i < m; i ++ )
                {
                    if(vhcs[j].st < det[i] || vhcs[j].d > det[i]) continue;
                    int d = vhcs[j].d, v = vhcs[j].v, a = vhcs[j].a;
                    if(sp(d, v, a, det[i]) > V) 
                    {
                        if(!state[j]) cnt ++;
                        dvcs[det[i]].push_back(j);
                        state[j] ++;
                        //printf("%lf %dbey ", sp(d, v, a, det[i]), j);
                    }
                //else printf("%lf %dund ", sp(d, v, a, det[i]), j);
                }
                //puts("");
            }

            printf("%d ", cnt);
            cnt = 0;
            for (int i = 0; i < m; i ++ )
            {
                int p = det[i];
                bool flag = false;
                for(auto t : dvcs[p]) 
                {
                    if(state[t] == 1) flag = true;
                }
                if(!flag)
                {
                    for(auto t : dvcs[p]) state[t] --;
                    cnt ++;
                }
            }
            printf("%d\n", cnt);
        }
        else
        {
            int maxs = 0;
            for (int i = 0; i < n; i ++ )
            {
                scanf("%d%d%d", &vhcs[i].d, &vhcs[i].v, &vhcs[i].a);
                maxs = max(maxs, vhcs[i].d);
            }
            for(int i = 0; i < m; i ++ ) 
            {
                scanf("%d", &det[i]);
            }
            cnt = count(m - 1);
            printf("%d ", cnt);
            if(cnt == 0) 
            {
                printf("%d\n", m);
                continue;
            }
            printf("%d\n", m - 1);
        }
    }
    return 0;
}
